package com.user.basic.analyze.sex;

import com.entity.analyze.Sex;
import com.user.basic.analyze.handler.SexTypeHandler;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface SexAnalyzeMapper {

    @Select("SELECT sex AS name,count( sex ) AS 'count' FROM user GROUP BY sex")
    @Results(
            {
                    @Result(column = "name", typeHandler = SexTypeHandler.class)
            }
    )
    List<SexAnalyzeEntity> groupBySex();

    @Insert("INSERT INTO sex(id, name, total, percent, create_time) " +
            "VALUES (#{id}, #{name}, #{total}, #{percent}, #{createTime})")
    void save(Sex sex);
}
